<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [22, 3, 54, 12];
        arr.sort(); // 无参，默认按字符串排序、
        console.log(arr); // 按照第一个字符串排序

        let arr1 = [22, 3, 54, 12];
        // 按照数字排序
        arr1.sort(function (a, b) {
            return a - b;

        });
        console.log(arr1); // 解决了只看第一个字母的问题

        
    </script>
</body>

</html>